
//import cate_data from 'cate_data.js';
var cate_data = require('cate_data.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    category: [],
    selectItems:[],
    active: ""
  },

  //点击左侧类别事件
  catSelect: function(e) {
    var that = this;
    var selectArray = that.data.category.filter(function(x) {
      return x.title == e.target.dataset.title
    });
    
    var select_items=cate_data.getCateItems(e.target.dataset.id-1);

    that.setData({
      active: e.target.dataset.id,
      selectItems: select_items
    });
  },
  GoList: function(e) {
    //console.log(e);
    var title = e.currentTarget.dataset.title;
    var catid = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../goods/list/list?catid=' + catid + "&title=" + title
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    var cat= [];
    for (let index = 0; index < cat.length; index++) {
      var element = cat[index];
      element.items=[];
      for (let j = 0; j < 10; j++) {        
        element.items.push("");
      }
    }
     cat=cate_data.getCat();
 
     var s=cate_data.getCateItems(0);
    that.setData({
      category:cat,
      active: cat[0].id,
      selectItems: s
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.loading = this.selectComponent("#loading");
    this.loading.HideLoading();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
 

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})